// 当前这个模块，对API进行统一管理

import request from './request';
import mockRequest from './mock';

// 获取三级联动数据

// header -- /api/product/getBaseCategoryList get
export const reqCategoryList = () => {
	return request({
		url: '/product/getBaseCategoryList',
		method: 'get'
	});
};

// 请求mockbanner数据
export const reqGetBannerList = () => {
	return mockRequest({
		url: '/banner',
		method: 'get'
	});
};

// 获取floor数据
export const reqGetFloor = () => {
	return mockRequest({
		url: '/floor',
		method: 'get'
	});
};

// search -- 获取search搜索模块数据
export const reqGetSearchInfo = (params = {}) => {
	return request({
		url: '/list',
		method: 'post',
		data: params
	});
};

// detail -- 获取商品详情信息的接口 /api/item/{ skuId }
export const reqGoodsInfo = skuId => {
	return request({
		url: `/item/${skuId}`,
		method: 'get'
	});
};

// 将产品添加到购物车(获取更新某一个产品的个数)
// /api/cart/addToCart/{ skuId }/{ skuNum }
export const reqAddOrUpdateShopCart = (skuId, skuNum) => {
	return request({
		url: `/cart/addToCart/${skuId}/${skuNum}`,
		method: 'post'
	});
};

// 获取购物车列表数据
// /api/cart/cartList get
export const reqCartList = () => {
	return request({
		url: '/cart/cartList',
		method: 'get'
	});
};

// 删除购物车中商品
// /api/cart/deleteCart/{skuId} delete
export const reqDelateCartList = skuId => {
	return request({
		url: `/cart/deleteCart/${skuId}`,
		method: 'delete'
	});
};

// 切换商品选中状态
// /api/cart/checkCart/{skuID}/{isChecked} get
export const reqChangeChecked = (skuID, isChecked) => {
	return request({
		url: `/cart/checkCart/${skuID}/${isChecked}`,
		method: 'get'
	});
};

// ===================================================================
// 获取注册验证码
// /api/user/passport/sendCode/{phone} get
export const reqGetCode = phone => {
	return request({
		url: `/user/passport/sendCode/${phone}`,
		method: 'get'
	});
};

// 注册用户
// /api/user/passport/register post
export const reqUserRegister = data => {
	return request({
		url: `/user/passport/register`,
		method: 'post',
		data: data
	});
};

// 登录
// /api/user/passport/login post
export const reqUserLogin = data => {
	return request({
		url: '/user/passport/login',
		method: 'post',
		data
	});
};

// 获取用户信息，【需要带着用户的token向服务器要用户信息】
// /api/user/passport/auth/getUserInfo get
export const reqUserInfo = () => {
	return request({
		url: '/user/passport/auth/getUserInfo',
		method: 'get'
	});
};

// 退出登录
// /api/user/passport/logout get
export const reqLogOut = () => {
	return request({
		url: '/user/passport/logout',
		method: 'get'
	});
};

// ==================trade===========================
// 获取用户地址信息
export const reqAddressInfo = () => {
	return request({
		url: '/user/userAddress/auth/findUserAddressList',
		method: 'get'
	});
};

// 获取订单交易页信息
// /api/order/auth/trade get
export const reqOrderInfo = () => {
	return request({
		url: '/order/auth/trade',
		method: 'get'
	});
};

// 提交订单的接口
// /api/order/auth/submitOrder?tradeNo={tradeNo} post
export const reqSubmitOrder = (tradeNo, data) => {
	return request({
		url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
		method: 'post',
		data
	});
};

// ===============pay===================
// 获取订单支付信息
// /api/payment/weixin/queryPayStatus/{orderId} get
export const reqPayInfo = orderId => {
	return request({
		url: `/payment/weixin/createNative/${orderId}`,
		method: 'get'
	});
};

// 查询订单支付状态
// /api/payment/weixin/queryPayStatus/{orderId} get
export const reqPayStatus = orderId => {
	return request({
		url: `/payment/weixin/queryPayStatus/${orderId}`,
		method: 'get'
	});
};

// ===========================================
// 获取我的订单列表
// /api/order/auth/{page}/{limit} get
export const reqMyOrderList = (page, limit) => {
	return request({
		url: `/order/auth/${page}/${limit}`,
		method: 'get'
	});
};
